/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package common;

import java.awt.Component;
import java.io.*;
import javax.swing.JOptionPane;

/**
 *
 * @author DongVan
 */
public class function_common {
    public static void infoBox(Component cp, String infoMessage, String location)
    {
        JOptionPane.showMessageDialog(cp, infoMessage, "InfoBox: " + location, JOptionPane.INFORMATION_MESSAGE);
    }
    //Read file txt  list peer
    public static byte[] serialize(Object obj) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream os = new ObjectOutputStream(out);
        os.writeObject(obj);
        return out.toByteArray();
    }
    
    public static myPackage.Package deserialize(byte[] data) throws IOException, ClassNotFoundException {
        ByteArrayInputStream in = new ByteArrayInputStream(data);
        ObjectInputStream is = new ObjectInputStream(in);
        return (myPackage.Package)is.readObject();
    }
}
